//
// Created by RandBII on 2020/12/28.
//

#ifndef FFMPEGFORANDROID_GLHELPER_H
#define FFMPEGFORANDROID_GLHELPER_H

#include <string>
#include <GLES3/gl3.h>
#include <glm.hpp>
#include "GLHelper.h"
#include "LogUil.h"

class GLHelper {
public:
    static GLuint LoadShader(GLenum shaderType, const char *pSource);

    static GLuint CreateProgram(const char *pVertexShaderSource, const char *pFragmentShaderSource,
                                GLuint &vertexShaderHandle, GLuint &fragmentShaderHandle);

    static GLuint CreateProgram(const char *pVertexShaderSource, const char *pFragmentShaderSource);

    static GLuint CreateProgramWithCallBack(const char *pVertexShaderSource,
                                            const char *pFragmentShaderSource,
                                            GLuint &vertexShaderHandle,
                                            GLuint &fragmentShaderHandle,
                                            const GLchar **varying,
                                            int varyingCount);

    static void DeleteProgram(GLuint &program);

    static void CheckGLError(const char *pGLOperation);

    static void SetBool(GLuint programId, const std::string &name, bool value);

    static void SetInt(GLuint programId, const std::string &name, int value);

    static void SetFloat(GLuint programId, const std::string &name, float value);

    static void SetVec2(GLuint programId, const std::string &name, const glm::vec2 &value);

    static void SetVec2(GLuint programId, const std::string &name, float x, float y);

    static void SetVec3(GLuint programId, const std::string &name, float x, float y, float z);

    static void SetVec3(GLuint programId, const std::string &name, const glm::vec3 &value);

    static void SetVec4(GLuint programId, const std::string &name, const glm::vec4 &value);

    static void
    SetVec4(GLuint programId, const std::string &name, float x, float y, float z, float w);

    static void SetMat2(GLuint programId, const std::string &name, const glm::mat2 &mat2);

    static void SetMat3(GLuint programId, const std::string &name, const glm::mat3 &mat3);

    static void SetMat4(GLuint programId, const std::string &name, const glm::mat4 &mat4);

    static glm::vec3 textCoordToVertexCoord(glm::vec2 texCoord);

};


#endif //FFMPEGFORANDROID_GLHELPER_H
